/**
 * Orion Security Browser
 * BugSec Team
 * @author Tiago Natel de Moura
 *
 * @license LGPL
 *
 * @link http://blog.tiagomoura-design.com.br
 * @link http://www.botecounix.com.br
 * @link http://orionsec.googlecode.com
 *
 * @class <class>
 * @version <version>
 * @since <version>
 */

#include <QMenu>
#include "tabbar.h"

TabBar::TabBar(QWidget *parent)
    : QTabBar(parent)
{
    setContextMenuPolicy(Qt::CustomContextMenu);
    setAcceptDrops(true);
    setTabsClosable(true);
    setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);
    setMovable(true);

    connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));
}

TabBar::~TabBar()
{

}

void TabBar::contextMenuRequested(const QPoint &position)
{
    QMenu menu;
    menu.addAction(tr("Nova Aba"), this, SIGNAL(newTab()), QKeySequence::AddTab);
    int index = tabAt(position);
    if (-1 != index)
    {
        menu.addAction(tr("Fechar Aba"), this, SLOT(closeTab()));
    } else
        menu.addAction(tr("Fora da aba"), this, SLOT(teste()));

    menu.addAction(tr("Reload"), this, SLOT(teste()));
    menu.exec(QCursor::pos());
}



